CC:=gcc
log:=thirdparty/log.c thirdparty/log.h
CFLAGS := -g -O0 -Wall  # 添加调试信息并禁用优化

test_log: test/test_log.c $(log)
	$(CC) $(CFLAGS) -o $@ $^ -Ithirdparty/
	./$@
	rm $@

json:= thirdparty/cJSON.c thirdparty/cJSON.h

test_cjson: test/test_cjson.c $(json) $(log)
	$(CC) $(CFLAGS) -o $@ $^ -Ithirdparty/
	./$@
	rm $@

common:=app/app_common.c app/app_common.h

test_common: test/test_common.c $(common) $(log)
	$(CC) $(CFLAGS) -o $@ $^ -Ithirdparty/ -Iapp/
	./$@
	rm $@

message:=app/app_message.c app/app_message.h
cJSON:=thirdparty/cJSON.c thirdparty/cJSON.h
test_message: test/test_message.c $(message) $(common) $(log) $(cJSON)
	$(CC) $(CFLAGS) -o $@ $^ -Ithirdparty/ -Iapp/
	./$@
	rm $@

mqtt:=app/app_mqtt.c app/app_mqtt.h
test_mqtt: test/test_mqtt.c $(mqtt) $(log)
	$(CC) $(CFLAGS) -o $@ $^ -Ithirdparty/ -Iapp/ -lpaho-mqtt3c
	./$@
	rm $@

pool:=app/app_pool.c app/app_pool.h
test_pool: test/test_pool.c $(pool) $(log)
	$(CC) $(CFLAGS) -o $@ $^ -Ithirdparty/ -Iapp/
	./$@
	rm $@